package com.zhuoyian.zyalibrary.service;

import org.json.JSONObject;

import android.content.Context;
import android.util.Base64;

import com.zhuoyian.zyalibrary.model.ARModel;
import com.zhuoyian.zyalibrary.util.JSONHelper;
import com.zhuoyian.zyalibrary.util.StaticSetting;
import com.zhuoyian.zyalibrary.util.Util;

public class BaseService {
	Context context;

	public BaseService(Context context) {
		this.context = context;
	}

	protected ARModel getARModel(JSONObject object) {
		ARModel model = null;
		try {
			if (object != null) {
				model = JSONHelper.parseObject(object, ARModel.class);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return model;
	}

	protected String getPBindKey() {
		return new String(Base64.decode(
				Util.toStringHex(StaticSetting.PROJECTBINDKEY).getBytes(),
				Base64.DEFAULT));
	}

	protected String GetAPIUrl(String Method) {
		return new String(Base64.decode(
				Util.toStringHex(StaticSetting.SERVICEPATH).getBytes(),
				Base64.DEFAULT)) + "Api/" + Method;
	}
}
